#include <iostream>
#include<fstream>
#include<ctime>
#include<vector>
using namespace std;
vector<int> bubbleSort(vector<int> arr){
  for(int i = 0; i < arr.size(); i++){
    int k = 0;
    for(int j = 0; j < arr.size() - i - 1; j++){
      if (arr[j] > arr[j + 1]){
        int t = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = t;
        k++;
      }
    }
    if(k == 0){
      break;
    }
  }
  return arr;
}
int main() {
  ifstream fl;
  fl.open("m1_sorted.txt");
  vector<int> arr;
  int x;
  while(fl >> x){
    arr.push_back(x);
  }
  double start_time = clock();
  arr = bubbleSort(arr);
  double finish_time = clock();
  cout << "m1_sorted " << (finish_time - start_time)/1000 << " milliseconds" << endl;


  ifstream fl2;
  fl2.open("m2_reverse.txt");
  vector<int> arr2;
  int x2;
  while(fl2 >> x2){
    arr2.push_back(x2);
  }
  double start_time2 = clock();
  arr2 = bubbleSort(arr2);
  double finish_time2 = clock();
  cout << "m2_reverse " << (finish_time2 - start_time2)/1000 << " milliseconds" << endl;


  ifstream fl3;
  fl3.open("m3_shuffle.txt");
  vector<int> arr3;
  int x3;
  while(fl3 >> x3){
    arr3.push_back(x3);
  }
  double start_time3 = clock();
  arr3 = bubbleSort(arr3);
  double finish_time3 = clock();
  cout << "m3_shuffle " << (finish_time3 - start_time3)/1000 << " milliseconds" << endl;
}